package org.cosmact.designer.vxml.gefeditor.editpart.policy;

import org.cosmact.designer.vxml.gefeditor.editpart.command.DialogDeleteCommand;
import org.cosmact.vxml.model.Dialog;
import org.cosmact.vxml.model.Document;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;

public class DialogComponentEditPolicy extends ComponentEditPolicy {

	
	@Override
	protected Command createDeleteCommand(GroupRequest deleteRequest) {
		Object parent = getHost().getParent().getModel();
		Object child = getHost().getModel();
		if (parent instanceof Document && child instanceof Dialog) {
			return new DialogDeleteCommand((Document) parent, (Dialog) child);
		}
		return super.createDeleteCommand(deleteRequest);
	}

}
